package com.example.products.service.impl;

import com.example.products.mapper.ProductsMapper;
import com.example.products.pojo.Products;
import com.example.products.service.ProductsService;
import org.apache.kafka.common.protocol.types.Field;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

@Service
public class ProductsServiceImpl implements ProductsService {
    @Autowired
    private ProductsMapper productsMapper;
    @Autowired
    private RestTemplate restTemplate;
    @Override
    public int save(Products product) {
        return productsMapper.insert(product);
    }
    @Override
    public Map<String,Object> queryByName(String name) {
        String url = "http://127.0.0.1:8082/es/query/"+name;
        Map<String,Object> map = restTemplate.getForObject(url, Map.class);
        return map;
    }
}
